package example.demo.component;

import example.demo.controller.GameController;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

//invokeBeanFactoryPostProcessors(beanFactory);
@Component
public class CustomerBeanFactoryPostProcessor implements BeanFactoryPostProcessor, EnvironmentAware {
    @Autowired
    GameController gameController;//null的
    @Value("${server.port}")
    Integer port;//0

    public static ConfigurableListableBeanFactory configurableListableBeanFactory;
    public static Environment environment;

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        CustomerBeanFactoryPostProcessor.configurableListableBeanFactory = beanFactory;
    }

    @Override
    public void setEnvironment(Environment environment) {
        CustomerBeanFactoryPostProcessor.environment = environment;
    }

//    @PostConstruct
}
